#include "datetimeparsertest.h"
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#include "common/logger/logger.h"
DateTimeParserTest::DateTimeParserTest(QObject* parent)
{
}
void DateTimeParserTest::initTestCase()
{
	LOG_INFO("测试开始");
}
void DateTimeParserTest::tstDateTimeParser()
{
	QString input_0 = "";
	QString result_0 = DateTimeParser::parseDateTimeSmart(input_0);
	LOG_INFO("input:{}，result0: ", result_0);

	QString input_1 = "25";
	QString result_1 = DateTimeParser::parseDateTimeSmart(input_1);
	LOG_INFO("input:25，result1: ", result_1);

	QString input_2 = "251";
	QString result_2 = DateTimeParser::parseDateTimeSmart(input_2);
	LOG_INFO("input:251，result2: ", result_2);

	QString input_3 = "2511";
	QString result_3 = DateTimeParser::parseDateTimeSmart(input_3);
	LOG_INFO("input:2511，result3: ", result_3);

	QString input_4 = "25111112";
	QString result_4 = DateTimeParser::parseDateTimeSmart(input_4);
	LOG_INFO("input:25111112，result4: ", result_4);

	QString input_5 = "251199121222";
	QString result_5 = DateTimeParser::parseDateTimeSmart(input_5);
	LOG_INFO("input:251199121222，result5: ", result_5);

	QString input_6 = "251111121222055555";
	QString result_6 = DateTimeParser::parseDateTimeSmart(input_6);
	LOG_INFO("input:251111121222055555，result6: ", result_6);

	QString input_7 = "25/12/12";
	QString result_7 = DateTimeParser::parseDateTimeSmart(input_7);
	LOG_INFO("input:25/12/12，result7: ", result_7);

	QString input_8 = "25/12/12 12.22.36";
	QString result_8 = DateTimeParser::parseDateTimeSmart(input_8);
	LOG_INFO("input:25/12/12，result8: ", result_8);

	QString input_9 = "25/999/12 12.22.36";
	QString result_9 = DateTimeParser::parseDateTimeSmart(input_9);
	LOG_INFO("input:25/999/12 12.22.36，result9: ", result_9);

	QCOMPARE(result_4, "2511-11-12 00:00");
	QCOMPARE(result_7, "2025-12-12 00:00");
}
void DateTimeParserTest::cleanupTestCase()
{
}
int main(int argc, char** argv)
{
	// 设置Windows控制台编码
#ifdef Q_OS_WIN
	// 设置控制台输出代码页为 UTF-8
	SetConsoleOutputCP(CP_UTF8);
	// 可选：设置控制台输入为 UTF-8
	SetConsoleCP(CP_UTF8);
#endif
	QApplication app(argc, argv);
	DateTimeParserTest tc;
	return QTest::qExec(&tc, argc, argv);// qExec 会把失败信息打印到 stdout
}